<template>
  <section>
    <div class="info">
      <p class="photo"><img :src="'https://i.hunnu.edu.cn/ums/avatar/' + userInfo.userAccount" alt="" /></p>
      <div>
        <h3>{{userInfo.userName}}</h3>
        <span >{{userInfo.unionName}} | {{userInfo.position}}</span>
      </div>
    </div>
    <div class="imgList">
      <div class="imgListHd">我的图集</div>
      <van-empty v-if="imgData.attachment.length==0" description="您还没上传图片哦" />
      <div class="imgListBd">
         <div class="imgItem" v-for="(item,i) in imgData.attachment" :key="i"  @click="getImg(item, i, imgData.attachment)">
           <img :src="item" alt="">
           <p><span>上传时间：{{imgData.createTime}}</span> <span>查看</span></p>
         </div>
      </div>
    </div>
    <tabbar :index="index" />
  </section>
</template>

<script>
import api from "@/data/api/index.js";
import tabbar from "../../components/tabbar.vue";
import Vue from 'vue';
import { ImagePreview ,Empty} from 'vant';
Vue.use(ImagePreview).use(Empty);
export default {
  components: { tabbar },
  data() {
    return {
      index: 2,
      userInfo: {},
      imgData:{
        createTime:'',
        attachment:[]
      }

    };
  },
  mounted (){

    this.userInfo = JSON.parse(sessionStorage.getItem("user"))
    this.identity = JSON.parse(sessionStorage.getItem("jurisdiction"));
    this.getList()
  },
  methods: {
    getList(){
      let _str=JSON.parse(this.$route.query.tdata);
      api.showMyActivity(_str.id).then(res=>{
        this.imgData.createTime=res.createTime
        res.attachment.map(item=>{
          this.imgData.attachment.push(`/api/file/${item.url}`)
        })
      })
    },
    getImg(item, i, e) {
      ImagePreview({
        images: e,
        showIndex: true,
        loop: false,
        startPosition: i
      });
    }
  },
};
</script>

<style lang="scss" scoped>
  section {
    .info{
      background:url(../imgs/imguserbg.jpg) no-repeat right bottom;
    background-size: 100% 100%;
      position: relative;
      padding: 20px;
      height: 65px;
      .photo {
        float: left;
        border-radius: 50%;
        background: #e3ddc7;
        // border: 1px solid #ccc;
        overflow: hidden;
        img {
          width: 65px;
          height: 65px;
        }
      }
      div {
        margin-left: 80px;
        h3 {
          font-size: 20px;
          font-weight: normal;
        }
        span {
          display: inline-block;
          margin-top: 5px;
          color: #fff;
          font-size: 12px;
          padding: 5px 15px;
          border-radius: 20px;
          background: linear-gradient(to right top,#FEB692, #EA5455);
          font-size: 12px;
        }
      }
      > span {
        position: absolute;
        top: 15px;
        right: 0;
        color: #fff;
        font-size: 13px;
        padding: 5px 10px;
        background: #e20010;
        border-radius: 25px 0 0 25px;
      }
    }
    .imgList{
      padding: 0 20px 20px;
      margin-bottom: 40px;
      .imgListHd{
        font-size: 16px;
        padding-bottom: 5px;
      }
      .imgItem{
        background-color: #fff;
        box-shadow: 0 0 8px #ddd;
        margin: 10px 0;
        >img{
          width: 100%;
        }
        >p{
          display: flex;
          align-items: center;
          line-height: 20px;
          justify-content: space-between;
          padding: 10px 8px;
          >span:nth-child(2){
            color: #fd784e;
            font-size: 15px;
          }
        }
      }
    }
  }

</style>
